﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TreeDataStructure
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create Tree
            Tree T;
            T = new Tree(0,0,100);
            //Call VisitAll
            VisitAll(T);
            //Call SplitLEafs()
            SplitLeafs(T);
            //Call LeafReport()
            LeafReport(T);
            //Call SplitLeafs()
            SplitLeafs(T);
            //Call VisitAll()
            VisitAll(T);
            
        }

        private static void LeafReport(Tree T)
        //precondion: Leaf nodes exist
        //postcondition: All the Report() methods from the leaf nodes have been called
        {
            //for (int i = 0; i < T.localID; i++)
           // {
                T.Report(T);
            //}
        }

        static void SplitLeafs(Tree refrenceNode)
        //precondition: That a root node or leavs exists
        //postcondtion: All leafs have created two children
        {
            refrenceNode.newNode(refrenceNode.globalID, 0,refrenceNode.rightLeaf);
            refrenceNode.newNode(refrenceNode.globalID, 0, refrenceNode.leftLeaf);
        }

        static void VisitAll(Tree refrenceNode)
        //precondition: nodes exists
        //postcondition: The Report() method has been called in all the nodes
        {
            if (refrenceNode != null)
            {
                refrenceNode.Report(refrenceNode);
            }
        }
    }
}